import React, { Component } from 'react';
import PropTypes from 'prop-types'
import DemoChild11 from './child11';
//书写组件 
class DemoChild1 extends Component{
    static PropTypes={
        role:PropTypes.string.isRequired
    }
    render(){
        console.log('render',this)
        const {role,userinfo} = this.props
        return(
            <div className='child1'>
                用户名1（数据来自与父组件）
                {
                    role === 'admin'?(<div>
                            { Object.keys(userinfo).map(K=>{
                                    return(
                                        <div key={k}>
                                            {k}-{userinfo[k]}    
                                        </div>)
                            })}    
                        </div>):"没有权限"
                }
                <DemoChild11 usernamer={this.props.username}/>
            </div>
        )
    }
}

export default DemoChild1